local function main(userOb, msgData)
    if not msgData.pops then
        return
    end

    local configs = IMPORT_D:query("monsterdrop")
    if not configs then
        local result = {}
        result.code = 400
        userOb:send_packet("MSGS2COpenBox", result)
        return
    end

    local box = INVENTORY_D:get_prop_by_pos(userOb, msgData.pops)
    if not box then
        local result = {}
        result.code = 401
        userOb:send_packet("MSGS2COpenBox", result)
        return
    end

    local config = configs[box.level or userOb:get_level()]
    if not config then
        local result = {}
        result.code = 402
        userOb:send_packet("MSGS2COpenBox", result)
        return
    end

    --!消耗宝箱道具
    INVENTORY_D:remove_prop_by_pos(userOb, msgData.pops)

    if box.propId == 10002 then
        --! 累加开箱次数
        local boxWelfare = config.boxWelfare
        local open_number = userOb:set_open_number(userOb:get_open_number() % #boxWelfare + 1)

        --! 获取奖励数值
        local Awardvalue = config["boxDropNum"..boxWelfare[open_number]]
        if msgData.is_dobule and msgData.is_dobule > 0 then
            Awardvalue = Awardvalue * 2
        end

        --!增加钱币
        local itemtype = tonumber(boxWelfare[open_number])
        userOb:add_currency(itemtype, Awardvalue)

        local result = {}
        result.code = 200
        result.itemtype = itemtype
        result.propCount = INVENTORY_D:get_currency_show_count(userOb, itemtype, Awardvalue)
        result.open_number = open_number
        result.boxtype = box.propId
        result.is_dobule = msgData.is_dobule
        userOb:send_packet("MSGS2COpenBox", result)
    else
        --! 累加开箱次数
        local boxWelfare = config.silverBoxDrop
        local open_number = userOb:set_open_number_silver(userOb:get_open_number_silver() % #boxWelfare + 1)

        --! 获取奖励数值
        local Awardvalue = config["silverBoxDrop"..boxWelfare[open_number]]

        if msgData.is_dobule and msgData.is_dobule > 0 then
            Awardvalue = Awardvalue * 5
        end

        --!增加钱币
        local itemtype = tonumber(boxWelfare[open_number])
        userOb:add_currency(itemtype, Awardvalue)

        local result = {}
        result.code = 200
        result.itemtype = itemtype
        result.propCount = INVENTORY_D:get_currency_show_count(userOb, itemtype, Awardvalue)
        result.open_number = open_number
        result.boxtype = box.propId
        result.is_dobule = msgData.is_dobule
        userOb:send_packet("MSGS2COpenBox", result)
    end

    ITEM_D:send_currency_info(userOb)
    ITEM_D:send_props_info(userOb)
end

--注册方法
COMMAND_D:register_command("MSGC2SOpenBox",GameCmdType.NONE, main)
